C   IMSL ROUTINE NAME   - LUREFN                                        LURN0010
C                                                                       LURN0020
C-----------------------------------------------------------------------LURN0030
C                                                                       LURN0040
C   COMPUTER            - HP1000/SINGLE                                 LURN0050
C                                                                       LURN0060
C   LATEST REVISION     - JUNE 1, 1982                                  LURN0070
C                                                                       LURN0080
C   PURPOSE             - NUCLEUS CALLED ONLY BY IMSL SUBROUTINE LEQT2F LURN0090
C                                                                       LURN0100
C   PRECISION/HARDWARE  - SINGLE AND DOUBLE/H32                         LURN0110
C                       - SINGLE/H36,H48,H60                            LURN0120
C                                                                       LURN0130
C   REQD. IMSL ROUTINES - SINGLE/LUELMN,UERTST,UGETIO                   LURN0140
C                       - DOUBLE/LUELMN,UERTST,UGETIO,VXADD,VXMUL,      LURN0150
C                           VXSTO                                       LURN0160
C                                                                       LURN0170
C   NOTATION            - INFORMATION ON SPECIAL NOTATION AND           LURN0180
C                           CONVENTIONS IS AVAILABLE IN THE MANUAL      LURN0190
C                           INTRODUCTION OR THROUGH IMSL ROUTINE UHELP  LURN0200
C                                                                       LURN0210
C   COPYRIGHT           - 1982 BY IMSL, INC. ALL RIGHTS RESERVED.       LURN0220
C                                                                       LURN0230
C   WARRANTY            - IMSL WARRANTS ONLY THAT IMSL TESTING HAS BEEN LURN0240
C                           APPLIED TO THIS CODE. NO OTHER WARRANTY,    LURN0250
C                           EXPRESSED OR IMPLIED, IS APPLICABLE.        LURN0260
C                                                                       LURN0270
C-----------------------------------------------------------------------LURN0280
C                                                                       LURN0290
      SUBROUTINE LUREFN (A,IA,N,UL,IUL,B,IDGT,APVT,X,RES,DX,IER)        LURN0300
C                                                                       LURN0310
      DIMENSION          A(IA,1),UL(IUL,1),B(1),X(1),RES(1),DX(1)       LURN0320
      DIMENSION          APVT(1)                                        LURN0330
      REAL               DNORM                                          LURN0340
      DOUBLE PRECISION   SUM                                            LURN0350
      DATA               ITMAX/50/,ZERO/0.0/                            LURN0360
C                                  FIRST EXECUTABLE STATEMENT           LURN0370
      IER=0                                                             LURN0380
      XNORM = ZERO                                                      LURN0390
      DO 10 I=1,N                                                       LURN0400
         XNORM = AMAX1(XNORM,ABS(X(I)))                                 LURN0410
   10 CONTINUE                                                          LURN0420
      IF (XNORM .NE. ZERO) GO TO 20                                     LURN0430
      IDGT = 50                                                         LURN0440
      GO TO 9005                                                        LURN0450
   20 DO 45 ITER=1,ITMAX                                                LURN0460
         DO 30 I=1,N                                                    LURN0470
            SUM = DBLE(B(I))                                            LURN0480
            DO 25 J=1,N                                                 LURN0490
               SUM = SUM - DBLE(A(I,J)) * DBLE(X(J))                    LURN0500
   25       CONTINUE                                                    LURN0510
            RES(I) = SUM                                                LURN0520
   30    CONTINUE                                                       LURN0530
         CALL LUELMN (UL,IUL,N,RES,APVT,DX)                             LURN0540
         DXNORM = ZERO                                                  LURN0550
         XNORM = ZERO                                                   LURN0560
         DO 35 I=1,N                                                    LURN0570
            X(I) = X(I) + DX(I)                                         LURN0580
            DXNORM = AMAX1(DXNORM,ABS(DX(I)))                           LURN0590
            XNORM = AMAX1(XNORM,ABS(X(I)))                              LURN0600
   35    CONTINUE                                                       LURN0610
         IF (ITER .NE. 1) GO TO 40                                      LURN0620
         IDGT = 50                                                      LURN0630
         IF (DXNORM .NE. ZERO) IDGT = -ALOG10(DXNORM/XNORM)             LURN0640
   40    DNORM = XNORM+DXNORM                                           LURN0650
   41    IF (DNORM .EQ. XNORM) GO TO 9005                               LURN0660
   45 CONTINUE                                                          LURN0670
C                                  ITERATION DID NOT CONVERGE           LURN0680
      IER = 129                                                         LURN0690
 9000 CONTINUE                                                          LURN0700
      CALL UERTST(IER,'LUREFN')                                         LURN0710
 9005 RETURN                                                            LURN0720
      END                                                               LURN0730
